﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VirtualPress.Infrastructure.Entities.Repository;
using VirtualPress.Infrastructure.Entities.Enum;

namespace VirtualPress.Infrastructure.Entities.Entity
{
    public class MeetingItem : IAccessible<T_MeetingItem, MeetingItem>, ILogicEntity<T_MeetingItem, MeetingItem>
    {
        #region Fileds
        public int Id { get; set; }
        public int ConferenceId { get; set; }
        /// <summary>
        /// 本期刊号
        /// </summary>
        public string Meetingcode { get; set; }

        /// <summary>
        /// 会议状态
        /// </summary>
        public MeetingItemStatus Status { get; set; }

        public DateTime StartDate { get; set; }
        /// <summary>
        /// 截稿日期
        /// </summary>
        public DateTime ArticleEndDate { get; set; }
        /// <summary>
        /// 会议地点
        /// </summary>
        public string Address { get; set; }
        /// <summary>
        /// 联系人
        /// </summary>
        public string ContactMan { get; set; }
        public string Phone { get; set; }
        public string Fax { get; set; }
        public string ZBDW { get; set; }
        public string CBDW { get; set; }
        /// <summary>
        /// 会议规模
        /// </summary>
        public string HYGM { get; set; }
        /// <summary>
        /// 联系邮箱
        /// </summary>
        public string Email { get; set; }
        /// <summary>
        /// 摘要
        /// </summary>
        public string Abstract { get; set; }

        /// <summary>
        /// 会议外链地址
        /// </summary>
        public string Link { get; set; }

        public int DownloadNumber { get; set; }
        public int VisitNumber { get; set; }
        /// <summary>
        /// 征稿启事
        /// </summary>
        public string CallForPaper { get; set; }
        /// <summary>
        /// 作者须知
        /// </summary>
        public string Announcement { get; set; }
        /// <summary>
        /// 会后旅游
        /// </summary>
        public string Travel { get; set; }
        /// <summary>
        /// 日程安排
        /// </summary>
        public string Schedule { get; set; }
        public string Catalog { get; set; }
        #endregion

        public List<Article> Articles { get; set; }

        protected override void Covariant(T_MeetingItem model)
        {
            if (model != null)
            {
                this.Abstract = model.Abstract;
                this.Address = model.Address;
                this.ArticleEndDate = model.ArticleEndDate;
                this.CBDW = model.CBDW;
                this.ConferenceId = model.ConferenceId;
                this.ContactMan = model.ContactMan;
                this.DownloadNumber = model.DownloadNumber;
                this.Email = model.Email;
                this.Fax = model.Fax;
                this.HYGM = model.HYGM;
                this.Status = (MeetingItemStatus)model.Status;
                this.Id = model.Id;
                this.Link = model.Link;
                this.Meetingcode = model.Meetingcode;
                this.Phone = model.Phone;
                this.StartDate = model.StartDate;
                this.VisitNumber = model.VisitNumber;
                this.ZBDW = model.ZBDW;
                this.Catalog = model.Catalog;
                this.CallForPaper = model.CallForPaper;
                this.Schedule = model.Schedule;
                this.Announcement = model.Announcement;
                this.Travel = model.Travel;
            }
        }

        protected override T_MeetingItem Inverter(MeetingItem model)
        {
            if (model != null)
            {
                return new T_MeetingItem()
                {
                    Abstract = model.Abstract,
                    Address = model.Address,
                    ArticleEndDate = model.ArticleEndDate,
                    CBDW = model.CBDW,
                    Status = (int)model.Status,
                    ConferenceId = model.ConferenceId,
                    ContactMan = model.ContactMan,
                    DownloadNumber = model.DownloadNumber,
                    Email = model.Email,
                    Fax = model.Fax,
                    HYGM = model.HYGM,
                    Id = model.Id,
                    Link = model.Link,
                    Meetingcode = model.Meetingcode,
                    Phone = model.Phone,
                    StartDate = model.StartDate,
                    VisitNumber = model.VisitNumber,
                    ZBDW = model.ZBDW,
                    Catalog = model.Catalog,
                    CallForPaper = model.CallForPaper,
                    Schedule = model.Schedule,
                    Announcement = model.Announcement,
                    Travel = model.Travel
                };
            }
            return null;
        }

        public MeetingItem Set(T_MeetingItem dbModel)
        {
            Covariant(dbModel);
            return this;
        }

        public MeetingItem SetArticles(List<Article> articles)
        {
            this.Articles = articles;
            return this;
        }
    }
}
